package com.newgrand.utils;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.TimeZone;

/**
 * @Author: zhanglixin
 * @Data: 2022/11/17 23:07
 * @Description: TODO
 */
@Service
public class HRJdbcTemplate {

    @Value("${hr.driver-class-name}")
    private String driverClassName;

    @Value("${hr.url}")
    private String hrUrl;

    @Value("${hr.username}")
    private String hrUsername;

    @Value("${hr.password}")
    private String hrPassword;

    public JdbcTemplate GetJdbcTemplate(){
        TimeZone timeZone = TimeZone.getTimeZone("Asia/Shanghai");
        TimeZone.setDefault(timeZone);
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driverClassName);
        dataSource.setUrl(hrUrl);
        dataSource.setUsername(hrUsername);
        dataSource.setPassword(hrPassword);

        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        return jdbcTemplate;
    }
}
